package com.zankong.tool.zkapp.views.text;

import android.view.ViewGroup;

import com.zankong.tool.zkapp.R;
import com.zankong.tool.zkapp.document.ZKDocument;
import com.zankong.tool.zkapp.views.ZKInputView;
import com.zankong.tool.zkapp.views.ZKPView;
import com.zankong.tool.zkapp.views.ZKViewAgent;

import org.dom4j.Attribute;
import org.dom4j.Element;

/**
 * Created by YF on 2018/7/17.
 */

public class Text_input extends ZKViewAgent {

    private ZKInputView mInput;
    private ZKPView mNum;

    /**
     * 构造函数,完成全局属性的解析
     *
     * @param zkDocument
     * @param element
     */
    public Text_input(ZKDocument zkDocument, Element element) {
        super(zkDocument, element);
    }

    @Override
    public void initView(ViewGroup viewGroup) {
        setContentView(R.layout.view_text_input);
        mInput = ((ZKInputView) findViewById(R.id.input));
        mNum = ((ZKPView) findViewById(R.id.num));
    }

    @Override
    public void fillData(Element viewElement) {
        for (Attribute attribute : viewElement.attributes()) {
            String value = attribute.getValue();
            switch (attribute.getName()) {
                case "num":
                    break;
                case "focusable":
                    if ("false".equals(value)){
                        getView().setFocusable(false);
                        getView().setFocusableInTouchMode(false);
                    }
                    break;
            }
        }
    }

    @Override
    public Object getResult() {
        return mInput.getText();
    }
}
